<title>Iteration vs Recursion.</title>
<body bgcolor=#f5deb3>
<hr>
<center>
<h1>Iteration vs Recursion</h1>
</center>
</hr>

Most problems that can be solved with iteration (
<a href=../SYNTAX/for.html>for</a>, 
<a href=../SYNTAX/while.html>while</a>, 
<a href=../SYNTAX/do.html>do</a> 
loops) can
also be solved with recursion. Pros and cons are:
<ul> 
<li>Iteration code will be faster and will use less resources.
<li>Recursion normaly looks more like the original formula.
</ul>
Anyway up, as an example of both technics here is some code to give the 
factorial of a number.
<a href=../EXAMPLES/fact1.c>Iteration</a>------
<a href=../EXAMPLES/fact2.c>Recursion</a>
<hr>
<p>
<center>
<table border=2 width=80% bgcolor=ivory>
<tr align=center>
<td width=25%>
<a href="../cref.html" target="_top">Top</a>
</td><td width=25%>
<a href="../master_index.html" target="_top">Master Index</a>
</td><td width=25%>
<a href="../SYNTAX/keywords.html" target="_top">C Keywords</a>
</td><td width=25%>
<a href="../FUNCTIONS/funcref.htm" target="_top">Functions</a>
</td>
</tr>
</table>
</center>
<p>
<hr>
<address> <a href=../../address.html>Martin Leslie</a> 
<script language="JavaScript">
<!--  //
document.write(document.lastModified);
// -->
</script>
</address>

